package com.wswy.wzcx.ui.main.garage

import android.graphics.Canvas
import android.graphics.Path
import android.graphics.Rect
import android.graphics.RectF
import com.blankj.utilcode.util.SizeUtils
import com.wswy.wzcx.widget.drawable.BaseDrawable

/**
 * 无需代办  / 立即代办的背景
 */
class HandleStatusDrawable(  bgColor:Int, shadowColor:Int
                           ) : BaseDrawable() {

    private val dy = SizeUtils.dp2px(2f).toFloat()
    private val effect = SizeUtils.dp2px(16f).toFloat()

    private val path = Path()

    private val rectF = RectF()

    init {

        paint.color = bgColor

        paint.setShadowLayer(effect,0f,dy,shadowColor)

    }


    override fun onBoundsChange(bounds: Rect?) {
        super.onBoundsChange(bounds)

        rectF.set(bounds)

        path.reset()

        path.moveTo(effect,rectF.height())
        path.quadTo(rectF.centerX(),-effect/2,rectF.width()-effect,rectF.height())

        path.close()

    }

    override fun draw(canvas: Canvas?) {

        canvas?.drawPath(path, paint)

    }
}